#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QtCharts>
#include "xcustomchart.h"
#include "xchartview.h"
#include "xserialportlist.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    void SelectWave(uint no);   //波形产生函数
    void Wave2Byte(const QLineSeries& ls,QByteArray& ba);    //波形变成字节数组
    QByteArray shortToByte(short i);    //int转QByteArray

private slots:
    void slot_serieHovered(const QPointF &, bool state);    //高亮曲线
    void slot_changeWave();//更换波形
    void slot_newPortList(QStringList portName);    //串口列表
    void slot_showFrq(int n); //当前频率显示
    void slot_openSerial(); //打开串口
    void slot_sendWave();   //发送波形

private:
    Ui::Widget *ui;
    XCustomChart* chart;    //图表
    QLineSeries* lineSeries;    //点序列
    QPen penSeries;             //画笔
    XChartView* pChartView;     //视图
    XSerialPortList* portlist;  //端口列表
    QSerialPort* serial;        //串口
    bool isOpened;    //串口是否打开
    QByteArray waveArray;   //波形队列
    short spotnum;        //点数
    short rbindex;          //当前rb状态
};
#endif // WIDGET_H
